var path = $('body').attr('ctxPath');
$(function(){
	$('#dashboard').dashboard({draggable: true});
	getProjectInfo();
	getOperationLogInfo();
	getRuleRecordInfo()
});

//获取项目ID
function getProjectId(){
	var projectId =$("#project_id").val();
	return projectId;
}

//项目信息相关操作
//首次获取数据
function getProjectInfo(){
	$.post(path+'/workbench/project/0?t='+new Date().getTime(),function(data){
		if(data.state){
			   $('#project_tbody').empty();
			   var html = [];
			   var projectList=data.list;
			   if(projectList!=null){
				for(var i = 0; i < projectList.length; i++){
					html.push("<tr data-id='"+projectList[i].id+"'><td>"+(i+1)+"</td> <td>"+projectList[i].projectCode+"</td><td>"+projectList[i].projectName+"</td><td>"+projectList[i].managerName+"</td><td>"+projectList[i].createDateStr+"</td> </tr>");
				}
				$('#project_tbody').append(html);
                if(projectList.length>=100){
                	$('#project_more').append("<button id='project_loading' type='button' class='btn btn-block loadingBtn' data-loading-text='正在加载中...'>点击加载更多</button>");
				}
                //点击项目列表的第一个
                $("#project_tbody tr:eq(0)").click();
		       }else{
					$('#project_tbody').append("<tr class='not_data' ><td colspan='5' align='center'>暂无数据</td></tr>");
					var projectId=getProjectId();
					getMaterialMoveInfo(projectId);
				    getPlanInfo(projectId)
				}
			  }else{
				  layer.alert(data.msg);
			  }
	}).error(function(){
		 layer.alert("网络异常,请刷新页面再试");
	});
}

//加载更多
$('#project_more').on('click','#project_loading', function() {
	var SN=$('#project_tbody').children("tr[class!='not_data']").length;
	var $btn = $(this);
	$btn.button('loading');
	var numberOld=$("#project_table_row").val();
	var number=Number(numberOld)+Number(100);
	$.post(path+'/workbench/project/'+number+'?t='+new Date().getTime(),function(data){
		var html = [];
		if(data.state){
			$("#project_table_row").val(number);
			    var projectList=data.list;
			    if(projectList!=null){
				for(var i = 0; i < projectList.length; i++){
					html.push("<tr data-id='"+projectList[i].id+"' ><td>"+(SN+i+1)+"</td> <td>"+projectList[i].projectCode+"</td><td>"+projectList[i].projectName+"</td><td>"+projectList[i].managerName+"</td><td>"+projectList[i].createDateStr+"</td> </tr>");
				}
				$('#project_tbody').append(html);
				$btn.button('reset');
			    }else{
			$('#project_tbody').append("<tr class='not_data'><td colspan='5' align='center'>暂无更多数据</td></tr>");
			$('#project_more').empty();
			   }
		}else{
			 layer.alert(data.msg);
			 $btn.button('reset');
		  }
	}).error(function(){
		 layer.alert("网络异常,请刷新页面再试");
		 $btn.button('reset');
	});
});

//刷新按钮
$('#project_refresh').on('click', function() {
	$("#project_table_row").val("0")
	$('#project_more').empty();
	$('#project_tbody').empty();
	$('#project_tbody').append("<tr class='not_data'><td colspan='5'><i class='icon icon-spin icon-spinner-indicator'></i></td></tr>");
	getProjectInfo();
});

//单击选中行
$("#project_tbody").on("click", "tr[class!='not_data']", function () {
	$("#project_tbody .activity").each(function () {
		 $(this).toggleClass('activity');
    });
    $(this).toggleClass('activity');
    $("#project_id").val($("#project_tbody .activity").attr('data-id'));
    var projectId=getProjectId();
    getMaterialMoveInfo(projectId);
    getPlanInfo(projectId)
});

//用户操作日志
//首次获取数据
function getOperationLogInfo(){
	$.post(path+'/workbench/log/0?t='+new Date().getTime(),function(data){
		if(data.state){
			var html = [];
			$('#log_tbody').empty();
			var logList=data.list;
		    if(logList!=null){
			for(var i = 0; i < logList.length; i++){
				html.push("<tr><td>"+(i+1)+"</td> <td>"+logList[i].operateDateStr+"</td><td>"+logList[i].operator+"</td><td>"+logList[i].operationTypeStr+"</tr>");
				}
			if(logList.length>=100){
				$('#log_more').append("<button id='log_loading' type='button' class='btn btn-block loadingBtn' data-loading-text='正在加载中...'>点击加载更多</button>");
			}
			$('#log_tbody').append(html);
		    }else{
		    	$('#log_tbody').append("<tr class='not_data'><td colspan='4' align='center'>暂无数据</td></tr>");
			}
			}else{
			 layer.msg(data.msg);
		}
	}).error(function(){
		 layer.alert("网络异常,请刷新页面再试");
	});
}

//加载更多
$('#log_more').on('click','#log_loading', function() {
	var SN=$('#log_tbody').children("tr[class!='not_data']").length;
	var $btn = $(this);
	$btn.button('loading');
	var numberOld=$("#log_table_row").val();
	var number=Number(numberOld)+Number(100);
	$.post(path+'/workbench/log/'+number+'?t='+new Date().getTime(),function(data){
		var html = [];
		if(data.state){
			$("#log_table_row").val(number);
			var logList=data.list;
		    if(logList!=null){
			for(var i = 0; i < logList.length; i++){
				html.push("<tr><td>"+(SN+i+1)+"</td> <td>"+logList[i].operateDateStr+"</td><td>"+logList[i].operator+"</td><td>"+logList[i].operationTypeStr+"</tr>");
			}
			$('#log_tbody').append(html);
			$btn.button('reset');
		    }else{
		    $('#log_tbody').append("<tr class='not_data'><td colspan='4' align='center'>暂无更多数据</td></tr>");
	     	$('#log_more').empty();
		   }
		}else{
			 layer.alert(data.msg);
			 $btn.button('reset');
		  }
	}).error(function(){
		 layer.alert("网络异常,请刷新页面再试");
		 $btn.button('reset');
	});
});
//刷新按钮
$('#log_refresh').on('click', function() {
	$("#log_table_row").val("0")
	$('#log_more').empty();
	$('#log_tbody').empty();
	$('#log_tbody').append("<tr class='not_data'><td colspan='4' ><i class='icon icon-spin icon-spinner-indicator'></i></td></tr>");
	getOperationLogInfo();
});
//获取计划信息
//首次加载
function getPlanInfo(projectId){
	$.post(path+'/workbench/plan/0?t='+new Date().getTime(),{"projectId":projectId},function(data){
		if(data.state){
			$('#planInfos').empty();
			   var planHtml =[];
			   var planList=data.obj;
			   if(planList!=null){
				   for(var i = 0; i < planList.length; i++){
					   var entryHtml=[];
					   var planHtmlChildBegin="<div class='plan-item'><div class='col-xs-12'><div class='plan-info clearfix'><div class='pull-left'>计划编码：<a style='text-decoration: none' href='javascript:void(0);'>"+planList[i].planCode+"</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
					   		"计划描述：<a style='text-decoration: none' href='javascript:void(0);'>"+planList[i].remark+"</a></div><div class='pull-right'>时间期间：<span class='text-primary'>"+planList[i].startDateStr+"&nbsp;&nbsp;至&nbsp;&nbsp;"+planList[i].endDateStr+"</span></div></div><div class='plan-map'>";
                       var entryHtmlChildException = "";
               	       var planHtmlChildOver="</div></div></div>";
               	       var planEntry=planList[i].planEntry;
					   if(planEntry!=null){
                     	     var entryHtmlChild="";
                             for (var x = 0; x < planEntry.length; x++) { 
                            	 var entryHtmlChildBegin="";
      						     var entryHtmlChildOver="";
                                 if(x!=planEntry.length-1){
                                     if(planEntry[x].states==1){ 
                                  	   if(planEntry[x].arrive==2){
                                  		   entryHtmlChildBegin = "<span data-id='"+planEntry[x].id+"' class='item-city item-city-error'>"+planEntry[x].addressName+"</span><span data-id='"+planEntry[x].id+"'  class='item-line item-line-error'>→<i class='icon icon-dot-circle'></i>→</span>";
                                  	   }else if(planEntry[x].arrive==1){
                                  		   entryHtmlChildBegin = "<span data-id='"+planEntry[x].id+"' class='item-city item-city-error'>"+planEntry[x].addressName+"</span><span data-id='"+planEntry[x].id+"'  class='item-line'>→<i class='icon icon-dot-circle'></i>→</span>";
                                  	   }else{
                                  		   entryHtmlChildBegin = "<span data-id='"+planEntry[x].id+"' class='item-city '>"+planEntry[x].addressName+"</span><span data-id='"+planEntry[x].id+"'  class='item-line'>→<i class='icon icon-dot-circle'></i>→</span>";
                                  	   }
                                     }else{   
                                  	   if(planEntry[x].arrive==2){
                                  		   entryHtmlChildBegin = "<span data-id='"+planEntry[x].id+"' class='item-city item-city-arrive'>"+planEntry[x].addressName+"</span><span data-id='"+planEntry[x].id+"'  class='item-line item-line-arrive'>→<i class='icon icon-dot-circle'></i>→</span>";
                                  	   }else if(planEntry[x].arrive==1){
                                  		   entryHtmlChildBegin = "<span data-id='"+planEntry[x].id+"' class='item-city item-city-arrive'>"+planEntry[x].addressName+"</span><span data-id='"+planEntry[x].id+"'  class='item-line'>→<i class='icon icon-dot-circle'></i>→</span>";
                                  	   }else{
                                  		   entryHtmlChildBegin = "<span data-id='"+planEntry[x].id+"' class='item-city '>"+planEntry[x].addressName+"</span><span data-id='"+planEntry[x].id+"'  class='item-line'>→<i class='icon icon-dot-circle'></i>→</span>";
                                  	   }
                                     }    
                               }else{
                                   if(planEntry[x].states==1){ 
                                  	 if(planEntry[x].arrive!=0){
                                  		 entryHtmlChildOver= "<span data-id='"+planEntry[x].id+"'  class='item-city item-city-error'>"+planEntry[x].addressName+"</span>";
                                  	 }else{
                                  		 entryHtmlChildOver= "<span data-id='"+planEntry[x].id+"'  class='item-city '>"+planEntry[x].addressName+"</span>";
                                  	 }
                                    }else{
                                  	  if(planEntry[x].arrive!=0){
                                   		 entryHtmlChildOver= "<span data-id='"+planEntry[x].id+"'  class='item-city item-city-arrive'>"+planEntry[x].addressName+"</span>";
                                   	 }else{
                                   		 entryHtmlChildOver= "<span data-id='"+planEntry[x].id+"'  class='item-city '>"+planEntry[x].addressName+"</span>";
                                   	 }
                                    }}
                                 entryHtmlChild=entryHtmlChildBegin+entryHtmlChildOver;
                                 entryHtml.push(entryHtmlChild);}
        					     if(planList[i].hasException==1){
        					    	   entryHtmlChildException = "<a href='javascript:void(0);'class='view-exception' data-id='"+planList[i].planId+"' >查看异常</a>" 
                                 }
        					     planHtml.push(planHtmlChildBegin+entryHtml.join(' ')+entryHtmlChildException+planHtmlChildOver);
                         }else{ 
                        	 if(planList[i].hasException==1){
  					    	   entryHtmlChildException = "<a href='javascript:void(0);'class='view-exception' data-id='"+planList[i].planId+"' >查看异常</a>" 
                              }
                        	  var entryHtml="<span class='col-xs-6' style='height: 30px;'>暂无数据</span>"  
                              planHtml.push(planHtmlChildBegin+entryHtml+entryHtmlChildException+planHtmlChildOver);
                         } 
				   }
				   if(planList.length>=100){
					   planHtml.push("<div id='plan_more' class='col-xs-12'><button id='plan_loading' type='button' class='btn btn-block loadingBtn' data-loading-text='正在加载中...'>点击加载更多</button></div>");
					   $('#planInfos').append(planHtml.join(' '));
				   }else{
					   $('#planInfos').append(planHtml.join(' '));
				   }
			   }else{
				   $('#planInfos').text("暂无数据");
			   }
		}else{
			layer.msg(data.msg);
		}
	}).error(function(){
		 layer.alert("网络异常,请刷新页面再试");
	});
}

//加载更多
$('#planInfos').on('click','#plan_loading', function() {
	var projectId=getProjectId();
	var $btn = $(this);
	$btn.button('loading');
	var numberOld=$("#plan_row").val();
	var number=Number(numberOld)+Number(100);
	$.post(path+'/workbench/plan/'+number+'?t='+new Date().getTime(),{"projectId":projectId},function(data){
		$("#plan_more").remove();
		if(data.state){
			$("#plan_row").val(number);
			   var planHtml =[];
			   var planList=data.obj;
			   if(planList!=null){
				   for(var i = 0; i < planList.length; i++){
					   var entryHtml=[];
					   var planHtmlChildBegin="<div class='plan-item'><div class='col-xs-12'><div class='plan-info clearfix'><div class='pull-left'>计划编码：<a style='text-decoration: none' href='javascript:void(0);'>"+planList[i].planCode+"</a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" +
					   		"计划描述：<a style='text-decoration: none' href='javascript:void(0);'>"+planList[i].remark+"</a></div><div class='pull-right'>时间期间：<span class='text-primary'>"+planList[i].startDateStr+"&nbsp;&nbsp;至&nbsp;&nbsp;"+planList[i].endDateStr+"</span></div></div><div class='plan-map'>";
                       var entryHtmlChildException = "";
            	       var planHtmlChildOver="</div></div></div>";
            	       var planEntry=planList[i].planEntry;
					   if(planEntry!=null){
                  	     var entryHtmlChild="";
                          for (var x = 0; x < planEntry.length; x++) { 
                         	 var entryHtmlChildBegin="";
  						     var entryHtmlChildOver="";
                             if(x!=planEntry.length-1){
                                 if(planEntry[x].states==1){ 
                              	   if(planEntry[x].arrive==2){
                              		   entryHtmlChildBegin = "<span data-id='"+planEntry[x].id+"' class='item-city item-city-error'>"+planEntry[x].addressName+"</span><span data-id='"+planEntry[x].id+"'  class='item-line item-line-error'>→<i class='icon icon-dot-circle'></i>→</span>";
                              	   }else if(planEntry[x].arrive==1){
                              		   entryHtmlChildBegin = "<span data-id='"+planEntry[x].id+"' class='item-city item-city-error'>"+planEntry[x].addressName+"</span><span data-id='"+planEntry[x].id+"'  class='item-line'>→<i class='icon icon-dot-circle'></i>→</span>";
                              	   }else{
                              		   entryHtmlChildBegin = "<span data-id='"+planEntry[x].id+"' class='item-city '>"+planEntry[x].addressName+"</span><span data-id='"+planEntry[x].id+"'  class='item-line'>→<i class='icon icon-dot-circle'></i>→</span>";
                              	   }
                                 }else{   
                              	   if(planEntry[x].arrive==2){
                              		   entryHtmlChildBegin = "<span data-id='"+planEntry[x].id+"' class='item-city item-city-arrive'>"+planEntry[x].addressName+"</span><span data-id='"+planEntry[x].id+"'  class='item-line item-line-arrive'>→<i class='icon icon-dot-circle'></i>→</span>";
                              	   }else if(planEntry[x].arrive==1){
                              		   entryHtmlChildBegin = "<span data-id='"+planEntry[x].id+"' class='item-city item-city-arrive'>"+planEntry[x].addressName+"</span><span data-id='"+planEntry[x].id+"'  class='item-line'>→<i class='icon icon-dot-circle'></i>→</span>";
                              	   }else{
                              		   entryHtmlChildBegin = "<span data-id='"+planEntry[x].id+"' class='item-city '>"+planEntry[x].addressName+"</span><span data-id='"+planEntry[x].id+"'  class='item-line'>→<i class='icon icon-dot-circle'></i>→</span>";
                              	   }
                                 }    
                           }else{
                               if(planEntry[x].states==1){ 
                              	 if(planEntry[x].arrive!=0){
                              		 entryHtmlChildOver= "<span data-id='"+planEntry[x].id+"'  class='item-city item-city-error'>"+planEntry[x].addressName+"</span>";
                              	 }else{
                              		 entryHtmlChildOver= "<span data-id='"+planEntry[x].id+"'  class='item-city '>"+planEntry[x].addressName+"</span>";
                              	 }
                                }else{
                              	  if(planEntry[x].arrive!=0){
                               		 entryHtmlChildOver= "<span data-id='"+planEntry[x].id+"'  class='item-city item-city-arrive'>"+planEntry[x].addressName+"</span>";
                               	 }else{
                               		 entryHtmlChildOver= "<span data-id='"+planEntry[x].id+"'  class='item-city '>"+planEntry[x].addressName+"</span>";
                               	 }
                                }}
                             entryHtmlChild=entryHtmlChildBegin+entryHtmlChildOver;
                             entryHtml.push(entryHtmlChild);}
     					     if(planList[i].hasException==1){
     					    	   entryHtmlChildException = "<a href='javascript:void(0);'class='view-exception' data-id='"+planList[i].planId+"'>查看异常</a>" 
                              }
     					     planHtml.push(planHtmlChildBegin+entryHtml+entryHtmlChildException+planHtmlChildOver);
                      }else{ 
                     	 if(planList[i].hasException==1){
					    	   entryHtmlChildException = "<a href='javascript:void(0);'class='view-exception' data-id='"+planList[i].planId+"'>查看异常</a>" 
                           }
                     	   var entryHtml="<span class='col-xs-6' style='height: 30px;'>暂无数据</span>"  
                           planHtml.push(planHtmlChildBegin+entryHtml.join(' ')+entryHtmlChildException+planHtmlChildOver);
                      } 
				   }
				   if(planList.length>=100){
					   planHtml.push("<div id='plan_more' class='col-xs-12'><button id='plan_loading' type='button' class='btn btn-block loadingBtn' data-loading-text='正在加载中...'>点击加载更多</button></div>");
					   $('#planInfos').append(planHtml.join(' '));
				   }else{
					   $('#planInfos').append(planHtml.join(' '));
				   }
			   }else{
				   $('#planInfos').append("<div class='plan-item'><div class='col-xs-12' style='text-align: center;'>暂无更多数据</div></div>");
			   }
		}else{
			layer.msg(data.msg);
		}
	}).error(function(){
		 layer.alert("网络异常,请刷新页面再试");
	});
});
//刷新按钮
$('#plan_refresh').on('click', function() {
	$("#plan_row").val("0")
	$('#planInfos').empty();
	$('#planInfos').append("<i class='icon icon-spin icon-spinner-indicator'></i>");
	getPlanInfo(getProjectId());
});

//点击查看异常
$('#planInfos').on('click','.view-exception', function() {
	$("#EXmodal .modal-body").empty();
	var planId = $(this).attr("data-id");
	$.post(path+'/workbench/exception/'+planId+'?t='+new Date().getTime(),function(data){
		if(data.state){
			$("#EXmodal").modal({show : true});
			var list=data.data;
			for ( var i in list) {
				$("#EXmodal .modal-body").append("<div class='col-xs-12'>"+list[i]+"</div>");
			}
		}else{
			layer.alert(data.msg);
		}
	}).error(function(){
		 layer.alert("网络异常,请刷新页面再试");
	});
});

//获取货物移动信息
//首次加载
function getMaterialMoveInfo(projectId){
	$.post(path+'/workbench/material/0?t='+new Date().getTime(),{"projectId":projectId},function(data){
		if(data.state){
			$('#materialMove_tbody').empty();
		   var html = [];
		   var materialMoveList=data.list;
		   if(materialMoveList!=null){
			for(var i = 0; i < materialMoveList.length; i++){
				html.push("<tr data-id='"+materialMoveList[i].materielId+"' ><td>"+(i+1)+"</td> <td>"+materialMoveList[i].materielCode+"</td><td>"+materialMoveList[i].materielName+"</td><td>"+materialMoveList[i].projectName+"</td><td>"+materialMoveList[i].planCode+"</td><td>"+materialMoveList[i].packingListCode+"</td><td>"+materialMoveList[i].containerCode+"</td><td>"+materialMoveList[i].addressName+"</td><td>"+materialMoveList[i].operationRecord+"</td><td>"+materialMoveList[i].operationDateStr+"</td> </tr>");
			}
			if(materialMoveList.length>=100){
				$('#materialMove_more').append("<button id='materialMove_loading' type='button' class='btn btn-block loadingBtn' data-loading-text='正在加载中...'>点击加载更多</button>");
			}
			$('#materialMove_tbody').append(html);
	       }else{
				$('#materialMove_tbody').append("<tr class='not_data'><td colspan='10' align='center' >暂无数据</td></tr>");
			}
		  }else{
			  layer.alert(data.msg);
		  }
	}).error(function(){
		 layer.alert("网络异常,请刷新页面再试");
	});
}

//加载更多
$('#materialMove_more').on('click','#materialMove_loading', function() {
	var SN=$('#materialMove_tbody').children("tr[class!='not_data']").length;
	var projectId=getProjectId();
	var $btn = $(this);
	$btn.button('loading');
	var numberOld=$("#materialMove_table_row").val();
	var number=Number(numberOld)+Number(100);
	$.post(path+'/workbench/material/'+number+'?t='+new Date().getTime(),{"projectId":projectId},function(data){
		var html = [];
		if(data.state){
			$("#materialMove_table_row").val(number);
			var materialMoveList=data.list;
			if(materialMoveList!=null){
				for(var i = 0; i < materialMoveList.length; i++){
					html.push("<tr data-id='"+materialMoveList[i].materielId+"' ><td>"+(SN+i+1)+"</td> <td>"+materialMoveList[i].materielCode+"</td><td>"+materialMoveList[i].projectName+"</td><td>"+materialMoveList[i].materielName+"</td><td>"+materialMoveList[i].projectName+"</td><td>"+materialMoveList[i].planCode+"</td><td>"+materialMoveList[i].packingListCode+"</td><td>"+materialMoveList[i].containerCode+"</td><td>"+materialMoveList[i].addressName+"</td><td>"+materialMoveList[i].operationRecord+"</td><td>"+materialMoveList[i].operationDateStr+"</td> </tr>");
				}
				$('#materialMove_tbody').append(html);
				$btn.button('reset');
			    }else{
			    $('#materialMove_tbody').append("<tr class='not_data'><td colspan='10' align='center'>暂无更多数据</td></tr>");
		     	$('#materialMove_more').empty();
			   }
		}else{
			 layer.alert(data.msg);
			 $btn.button('reset');
		  }
	}).error(function(){
		 layer.alert("网络异常,请刷新页面再试");
		 $btn.button('reset');
	});
});

//刷新按钮
$('#materialMove_refresh').on('click', function() {
	$("#materialMove_table_row").val("0")
	$('#materialMove').empty();
	$('#materialMove_tbody').empty();
	$('#materialMove_tbody').append("<tr class='not_data'><td colspan='10' ><i class='icon icon-spin icon-spinner-indicator'></i></td></tr>");
	getMaterialMoveInfo(getProjectId());
});

//获取打尺异常信息
//首次加载
function getRuleRecordInfo(){
	$.post(path+'/workbench/rule/0?t='+new Date().getTime(),function(data){
		if(data.state){
			$('#rule_tbody').empty();
			   var html = [];
			   var ruleList=data.list;
			   if(ruleList!=null){
				for(var i = 0; i < ruleList.length; i++){
					html.push("<tr data-id='"+ruleList[i].id+"'><td>"+(i+1)+"</td> <td>"+ruleList[i].resourceCode+"</td><td>"+ruleList[i].resourceName+"</td><td>"+ruleList[i].length+"</td><td>"+ruleList[i].width+"</td><td>"+ruleList[i].height+"</td><td>"+ruleList[i].volume+"</td><td>"+ruleList[i].weight+"</td><td>"+ruleList[i].operator+"</td><td>"+ruleList[i].positionName+"</td><td>"+ruleList[i].ruleDateStr+"</td>  </tr>");
				}
				if(ruleList.length>=100){
					$('#rule_more').append("<button id='rule_loading' type='button' class='btn btn-block loadingBtn' data-loading-text='正在加载中...'>点击加载更多</button>");
				}
				$('#rule_tbody').append(html);
		       }else{
					$('#rule_tbody').append("<tr class='not_data'><td colspan='12' align='center' >暂无数据</td></tr>");
				}
			  }else{
				  layer.alert(data.msg);
			  }
	}).error(function(){
		 layer.alert("网络异常,请刷新页面再试");
	});
}
//加载更多
$('#rule_more').on('click','#rule_loading', function() {
	var SN=$('#materialMove_tbody').children("tr[class!='not_data']").length;
	var $btn = $(this);
	$btn.button('loading');
	var numberOld=$("#rule_table_row").val();
	var number=Number(numberOld)+Number(100);
	$.post(path+'/workbench/rule/'+number+'?t='+new Date().getTime(),function(data){
		var html = [];
		if(data.state){
			$("#rule_table_row").val(number);
			    var ruleList=data.list;
			    if(ruleList!=null){
				for(var i = 0; i < ruleList.length; i++){
					html.push("<tr data-id='"+ruleList[i].id+"'><td>"+(SN+i+1)+"</td> <td>"+ruleList[i].resourceCode+"</td><td>"+ruleList[i].resourceName+"</td><td>"+ruleList[i].length+"</td><td>"+ruleList[i].width+"</td><td>"+ruleList[i].height+"</td><td>"+ruleList[i].containerCode+"</td><td>"+ruleList[i].volume+"</td><td>"+ruleList[i].weight+"</td><td>"+ruleList[i].operator+"</td><td>"+ruleList[i].positionName+"</td><td>"+ruleList[i].ruleDateStr+"</td>  </tr>");
				}
				$('#rule_tbody').append(html);
				$btn.button('reset');
			    }else{
			    $('#rule_tbody').append("<tr class='not_data'><td colspan='12' align='center'>暂无更多数据</td></tr>");
		     	$('#rule_more').empty();
			   }
		}else{
			 layer.alert(data.msg);
			 $btn.button('reset');
		  }
	}).error(function(){
		 layer.alert("网络异常,请刷新页面再试");
		 $btn.button('reset');
	});
});

//刷新按钮
$('#rule_refresh').on('click', function() {
	$("#rule_table_row").val("0")
	$('#rule_more').empty();
	$('#rule_tbody').empty();
	$('#rule_tbody').append("<tr class='not_data'><td colspan='12' ><i class='icon icon-spin icon-spinner-indicator'></i></td></tr>");
	getRuleRecordInfo();
});


